package com.ruoyi.web.controller.retirement;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.retirement.domain.RetirementCarousel;
import com.ruoyi.retirement.service.IRetirementCarouselService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 轮播图配置Controller
 * 
 * @author 曹旭
 * @date 2025-09-03
 */
@RestController
@RequestMapping("/retirement/retirementCarousel")
public class RetirementCarouselController extends BaseController
{
    @Autowired
    private IRetirementCarouselService retirementCarouselService;

    /**
     * 查询轮播图配置列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:list')")
    @GetMapping("/list")
    public TableDataInfo list(RetirementCarousel retirementCarousel)
    {
        startPage();
        List<RetirementCarousel> list = retirementCarouselService.selectRetirementCarouselList(retirementCarousel);
        return getDataTable(list);
    }

    /**
     * 导出轮播图配置列表
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:export')")
    @Log(title = "轮播图配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RetirementCarousel retirementCarousel)
    {
        List<RetirementCarousel> list = retirementCarouselService.selectRetirementCarouselList(retirementCarousel);
        ExcelUtil<RetirementCarousel> util = new ExcelUtil<RetirementCarousel>(RetirementCarousel.class);
        util.exportExcel(response, list, "轮播图配置数据");
    }

    /**
     * 获取轮播图配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(retirementCarouselService.selectRetirementCarouselById(id));
    }

    /**
     * 新增轮播图配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:add')")
    @Log(title = "轮播图配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RetirementCarousel retirementCarousel)
    {
        return toAjax(retirementCarouselService.insertRetirementCarousel(retirementCarousel));
    }

    /**
     * 修改轮播图配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:edit')")
    @Log(title = "轮播图配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RetirementCarousel retirementCarousel)
    {
        return toAjax(retirementCarouselService.updateRetirementCarousel(retirementCarousel));
    }

    /**
     * 删除轮播图配置
     */
    @PreAuthorize("@ss.hasPermi('retirement:retirementCarousel:remove')")
    @Log(title = "轮播图配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(retirementCarouselService.deleteRetirementCarouselByIds(ids));
    }
}
